﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace TeamBuy.AccessWebUI.Components.DefaultPages
{
    public partial class Side_TopAD : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AccessService.TeamBuyAdvertisementService getTopAd = new AccessService.TeamBuyAdvertisementService();
            DataTable dtAd = getTopAd.GetAdByPosition(1, 1);
            if (dtAd.Rows.Count > 0)
            {
                imgAD.ImageUrl = dtAd.Rows[0]["AdImage"].ToString();
                lnkAD.NavigateUrl = dtAd.Rows[0]["AdLink"].ToString();
                if (Convert.ToBoolean(dtAd.Rows[0]["IsShowInNewPage"]) == true)
                {
                    lnkAD.Target = "_blank";
                }
            }
            else
            {
                this.Visible = false;
            }
        }
    }
}